const http = require('http')
const url = require('url')
const {
    userFind
} = require('./model/user_model')
// 创建WEB服务
const port = 8080
const server = http.createServer((req, res) => {
    let findData = null
    let obj = url.parse(req.url, true).query
    let handle = function (err, data) {
        if (err) {
            findData = {
                message: '未查询到相关数据 登录失败',
                data: []
            }
        } else {
            findData = {
                data: data
            }
        }
        let dataReturn = {
            code: 200,
            data: findData
        }
        res.end(JSON.stringify(dataReturn))
    }
    res.setHeader("Access-Control-Allow-Origin", "*");
    userFind(obj, handle)
})

server.listen(port)